/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package length;

import rule.Rule;
import score.Score;

/**
 *
 * @author Daniel Gribel
 */
public class Length01 extends Length {
    
    public static final int[] lengthInterval = {5, 8, 16, Integer.MAX_VALUE};
    public static final int[] scoreAssigned = {3, 6, 12, 18};
	
	public Length01(Score score) {
            this.setScore(score);
	}

	@Override
	public void calculate(String dataEntry) {
            int lengthScore = classifyLength(dataEntry);
            setLength(dataEntry.length());
            getScore().applyScore(lengthScore);
	}
	
	private int classifyLength(String dataEntry) {
        for (int i = 0; i < lengthInterval.length; i++) {
            if (dataEntry.length() < lengthInterval[i])
                return scoreAssigned[i];
        }
        return scoreAssigned[scoreAssigned.length - 1];
    }

}
